#!/usr/bin/env python 
# -*- coding: utf-8 -*-  
import math

class Line:
    def __init__(self, _start_point, _end_point=None):
        self.start_point, self.end_point = _start_point, _end_point
        self.point_array = []
        self.special_point_array = []
        self.special_point_array.append(_start_point)
        self.section_array = []
        self.type = ""
        
    def get_start_point(self):
        return self.start_point
    
    def get_end_point(self):
        return self.end_point
    
    def set_start_point(self, _start_point):
        self.start_point = _start_point
    
    def set_end_point(self, _end_point):
        self.end_point = _end_point
    
    def get_direct_params(self):
        deltay = float((self.get_end_point().get_y() - self.get_start_point().get_y()))
        deltax = float((self.get_end_point().get_x() - self.get_start_point().get_x()))
        a,b = 0.0,0.0
        if deltax != 0:
            a = deltay/deltax
            b = self.get_start_point().get_y() - a*self.get_start_point().get_x()
        return (a,b)
    
    def get_point_array(self):
        return self.point_array
    
    def get_special_point_array(self):
        return self.special_point_array
    
    def set_special_point_array(self, _array):
        self.special_point_array = _array
    
    def get_section_array(self):
        return self.section_array
    
    def set_section_array(self, _array):
        self.section_array = _array
    
    def append_to_point_array(self, _point):
        self.point_array.append(_point)
    
    def append_to_special_point_array(self, _point):
        self.special_point_array.append(_point)
        
    def append_to_section_array(self, _section):
        self.section_array.append(_section)
        
    def get_type(self):
        return self.type
    
    def set_type(self, _type):
        self.type = _type
        
    def get_angle(self):
        deltay = float((self.end_point.get_y() - self.start_point.get_y()))
        deltax = float((self.end_point.get_x() - self.start_point.get_x()))
        if deltax != 0:
            angle = math.atan(deltay/deltax)
        else:
            angle = math.pi*deltay/(2*abs(deltay))
        return abs(angle)
        
